class cell:
    def __init__(self):
        import neuron as ne
        import nrn as n
        self.ne = ne
        self.n = n


    def make_cell(self):
        soma = self.soma = self.n.Section()
        axon = self.axon = self.n.Section()
        dend = self.dend = self.n.Section()

        soma.L = 30
        soma.nseg = 5

        axon.L = 1000
        axon.nseg = 30

        dend.L = 100
        dend.nseg = 10

        axon.connect(soma,0.5,1)
        dend.connect(soma)

        soma.insert('pas')
        axon.insert('hh')
        dend.insert('pas')

        self.vect = self.ne.Vector()
        soma.push()
        self.vect.record(self.ne.h.ref(soma(0.5).v))
        self.ne.h.pop_section()

    def run(self,tstop,v_init=-40):
        print "Before sim " + str(self.soma(0.5).v)
        self.ne.h.finitialize(v_init)
        self.ne.h.fcurrent()
        while self.ne.h.t < tstop:
            self.ne.h.fadvance()
        print "After sim " + str(self.soma(0.5).v)


c = cell()
c.make_cell()
c.run(1)



